import React, { Component, Children } from 'react'

// console.log(Children)

export default class Com extends Component {
    render() {
        // []
        // [{}]
        // [{}, {}, {}]
        const { children } = this.props
        // count  计算children的length
        // console.log(Children.count(children))
        // only  用来查看children是否只是为一个 (如果是返回当前dom结构，如果不是则报错)
        // console.log(Children.only(children))
        return (
            <div>
                <h3>我是一个组件</h3>
                <ul>
                    {
                        Children.map(children, (item, index) => {
                            return <li key={index}>
                                { item }
                            </li>
                        })
                    }
                </ul>
            </div>
        )
    }
}
